<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
 <%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
<title>ichange - 私信</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">

 	<link href="skin/reply_files/message.css" rel="stylesheet"
			type="text/css">
		<link type="text/css" href="skin/reply_files/wokaobox.css"
			rel="stylesheet" charset="utf-8" media="screen">

		<jsp:include page="../skin/jsp/files.jsp"></jsp:include>

		<!-- s -->
	  <script type='text/javascript' src='/dwr/engine.js'></script>
	  <script type='text/javascript' src='/dwr/interface/PM.js'></script>
	  <script type='text/javascript' src='/zgg/js/zgg.js'></script>

	</head>

	<body>


	
		
		<jsp:include page="header.jsp"></jsp:include>
  	
       
		<div id="content">
			<h2>
				<span><a href="pmtrackers">&lt;&lt;&nbsp;返回私件箱</a>
				</span>
			</h2>
			<div id="wrap">
				<form action="pmsend2" method="post"
					id="reply_form">
					<div class="reply-input">
						<p class="title">
							回复<a href="itemsProfileAction.action?userId=${tm.attr.to.id }">${tm.attr.to.name }</a>:
						</p>
						<textarea name="pc.content" id="pmContent" cols="" rows=""
							class="reply-back"></textarea>
						<input type="hidden" value="${tm.attr.to.name }" name="pc.receiptor.name" id="to_name"/>
						<input type="hidden" value="${tm.attr.to.id }" name="pc.receiptor.id"  id="to_id"  >
						<input type="hidden" value="${id }" name="pc.dialog.id" name="pc.dialog.id">
						<input type="hidden" value="${id }" name="id" name="id">
						
						<p class="btn-area">
							<span class="time">还可以输入<span class="wordNum"><span>300</span>
							</span>字</span>
							<input type="submit" value="发  送" class="send-btn">
						</p>
					</div>
				</form>
<script type="text/javascript" src="http://aui.github.com/artTemplate/template.js"></script>
				
				<script  type="text/javascript">
				<!--
				(function($){
$.fn.extend({
              serializeObject:function(){
                     if(this.length>1){
                            return false;
                     }
                     var arr=this.serializeArray();
                     var obj=new Object;
                     $.each(arr,function(k,v){
                            obj[v.name]=v.value;
                     });
                     return obj;
              }
       });
})(jQuery);

template.openTag = "<#";
template.closeTag = "#>";
				$(function (){
					$('form').submit(function (){
						
						//alert($(this).serializeObject());
						var that=this;
						PM.send({content:$('#pmContent',that).val(),receiptor:{name:$('#to_name',that).val()}},function (tm){
							if(tm && tm.success){
								//var html = template.render('item_tmpl', tm.attr.pc);
								//$(html).insertAfter('#item-top');
								$('#pmContent',that).val('');
							}else{
								alert(tm.message);
							}
						});

						

						return false;
					
					});

					dwr.engine.setActiveReverseAjax(true);
					//dwr.engine.setNotifyServerOnPageUnload(true);
					PM.turnOn(${id });
					
				
				});

				function update(pc){
					//zgg.log(pc.content);

					var html = template.render('item_tmpl', pc);
					$(html).insertAfter('#item-top');
				}

				function delelte(the){
					PM.removeContent($.parseJSON($(the).attr('data')),function (d){
						
						if(d){
							$(the).parents('.message-item').hide('slow');
						}
					});


				}

				//-->
				</script>


<script  type="text/html" id="item_tmpl">
 
  				 <div class="message-item message28810 cf">
					<a href="itemsProfileAction.action?userId=<#=sender.id#>" class="fl" title="<#=sender.name#>"><img
							src="<#=sender.photo#>"
							width="40" height="40">
						<input type="hidden" name="id" value="8805513311">
					</a>
					<div class="message_right dialogue-right fl">
						<span class="message-content"> <a
							href="itemsProfileAction.action?userId=<#=sender.id#>" class="names"
							title="<#=sender.name#>"><#=sender.name#>:</a> <#=content#></span>
						<span class="time"><s:date name="pubtime" format="yyyy-MM-dd hh:mm:ss"/>· <a
							href="javascript:void(0);"  onclick="delelte(this);return false;"  class="destory"  data='{"id":<#=id#>,"dialog":{"id":${id }}}'>删除</a>
						</span>
					</div>
				</div>
</script>

				
				 <s:iterator value="tm.data">
  
  		 <div id="item-top"></div>
  		 <div class="message-item message28810 cf">
					<a href="itemsProfileAction.action?userId=<s:property value="sender.id"/>" class="fl" title="<s:property value="sender.name"/>"><img
							src="<s:property value="sender.photo"/>"
							width="40" height="40">
						<input type="hidden" name="id" value="8805513311">
					</a>
					<div class="message_right dialogue-right fl">
						<span class="message-content"> <a
							href="itemsProfileAction.action?userId=${sender.id }" class="names"
							title="<s:property value="sender.name"/>"><s:property value="sender.name"/>:</a> <s:property value="content"/></span>
						<span class="time"><s:date name="pubtime" format="yyyy-MM-dd hh:mm:ss"/>· 
							<a
							href="javascript:void(0);"  onclick="delelte(this);return false;"  class="destory"  data='{"id":${id},"dialog":{"id":${dialog.id }}}'>删除</a>

						
						</span>
					</div>
				</div>
  		 
  		 
  		 
   		 </s:iterator>
		
			</div>
		</div>
		<!--end content-->

		<div id="footer">
		</div>
		<script type="text/javascript">
       jQuery.global.init();</script>

</script>
</html>
